import Vue from "vue"

const state = {
	goodsStatus: {}
};
const mutations = {
	set(state, { status, commodity_id, commodity_name, commodity_no } ) {
		var obj = {
			status,
			commodity_id,
			commodity_no,
			commodity_name
		}
		Vue.set(state.goodsStatus, commodity_id, obj);
	},
	clear(state) {
		for(var i in state.goodsStatus) {
			state.goodsStatus[i].status = 0;
		}
	}
}
const getters = {
	validGoods(state) {
		var goods = [];
		for(var item in state.goodsStatus) {
			if ( state.goodsStatus[item].status === 1) {
				goods.push(item)
			}
		}
		return goods.join(",");
	}
}
export default {
	namespaced: true,
	state,
	mutations,
	getters
}
